

CREATE PROCEDURE USP_RPT_DIARIO
AS
SELECT IT.inftra_matavi,
IT.INFTRA_FK_TLEADERID,
IT.INFTRA_FK_ENCARGID,
ITD.INFTRADET_ORIID,O.ORI_COD,
ITD.INFTRADET_FK_COMPID,C.SATA_CODATA,
SA.SATA_COD,
ITD.INFTRADET_DESCTRACOMP,
ITD.INFTRADET_FK_PRGNPRG,
ITD.PRGTRA_T_ESTIM_COMP,
ITD.INFTRADET_TRHH,
ITD.INFTRADET_OBSERVA
from HH_INF_TRAB IT INNER JOIN  dbo.HH_INFTRA_DET ITD
ON IT.INFTRA_ID = ITD.INFTRA_ID
INNER JOIN HH_ORIGEN O
ON ITD.INFTRADET_ORIID = O.ORI_ID
INNER JOIN HH_COMPONENTE C
ON ITD.INFTRADET_FK_COMPID = C.COMP_ID
INNER JOIN HH_SUBATA SA
ON C.SATA_CODATA = SA.SATA_CODATA
ORDER BY IT.inftra_matavi
GO


SELECT TOP 1 PER_ID FROM HH_PER_TRABPRG WHERE INFTRA_ID = '-2147483647' 
SELECT TOP LAST 2 PER_ID FROM HH_PER_TRABPRG WHERE INFTRA_ID = '-2147483647') 
SELECT TOP 3 PER_ID FROM HH_PER_TRABPRG WHERE INFTRA_ID = '-2147483647' 
SELECT TOP 4 PER_ID FROM HH_PER_TRABPRG WHERE INFTRA_ID = '-2147483647' 
SELECT MAX(SELECT TOP 3  PER_ID FROM HH_PER_TRABPRG WHERE INFTRA_ID = '-2147483647')


SELECT TOP 

SELECT * FROM HH_PER_TRABPRG

DECLARE @intFlag INT
DECLARE @LONG INT
SET @LONG = (SELECT COUNT(*) FROM HH_PER_TRABPRG WHERE INFTRA_ID = '-2147483647')
SET @intFlag = 1
SELECT 
WHILE (@intFlag <= @LONG)
  BEGIN
     PER_ID + @intFlag 
SET @intFlag = @intFlag + 1
  END
FROM HH_PER_TRABPRG WHERE  INFTRA_ID = '-2147483647'
GO

DECLARE @COUNT 
DECLARE @LONG INT
SET @LONG = (SELECT COUNT(*) FROM HH_PER_TRABPRG WHERE INFTRA_ID = '-2147483647')
SELECT WHILE  PER_ID FROM HH_PER_TRABPRG WHERE  INFTRA_ID = '-2147483647'

SELECT * FROM HH_PER_TRABPRG

WHILE (SELECT PER_ID FROM HH_PER_TRABPRG WHERE  INFTRA_ID = '-2147483647') < $300





 



SELECT * FROM HH_INF_TRAB
SELECT * FROM dbo.HH_INFTRA_DET
SELECT * FROM dbo.HH_ORIGEN
SELECT * FROM HH_COMPONENTE
SELECT * FROM HH_USUARIO


SELECT * FROM HH_PER_TRABPRG WHERE INFTRA_ID = '-2147483647'
SELECT * FROM HH_PERSONA_QA

SELECT * FROM HH_PARAM_VAL





